﻿using University.Workshop.Business;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;

namespace University.Workshop.Tests
{
    
    
    /// <summary>
    ///This is a test class for UserRegistrationManagerTest and is intended
    ///to contain all UserRegistrationManagerTest Unit Tests
    ///</summary>
    [TestClass()]
    public class UserRegistrationManagerTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for RegisterUser
        ///</summary>
        [TestMethod()]
        public void RegisterUserTestSuccesfully()
        {
            string firstName = "Pedro"; // TODO: Initialize to an appropriate value
            string lastName = "Suarez"; // TODO: Initialize to an appropriate value
            char gender = 'M'; // TODO: Initialize to an appropriate value
            Random rand = new Random();
            DateTime birthday = DateTime.Now.AddYears(-18); // TODO: Initialize to an appropriate value
            string email = "pedro"+rand.Next(400)+"@gmail.com"; // TODO: Initialize to an appropriate value
            //string email = "juan@hotmail.com";
            string password = "qwert1"; // TODO: Initialize to an appropriate value
            string rePassword = "qwert1"; // TODO: Initialize to an appropriate value
            string department = "Cochabamba"; // TODO: Initialize to an appropriate value
            string city = "Cercado"; // TODO: Initialize to an appropriate value
            string movilephone = "" + rand.Next(79999999); // TODO: Initialize to an appropriate value
            string phone = "" + rand.Next(4999999); // TODO: Initialize to an appropriate value
            Collection<RegisterError> actual;
            actual = UserRegistrationManager.RegisterUser(firstName, lastName, gender, birthday, email, password, rePassword, department, city, movilephone, phone);
            Assert.AreNotEqual(null, actual);
        }

        [TestMethod()]
        public void RegisterUserTestFail()
        {
            string firstName = "Pedr0"; // TODO: Initialize to an appropriate value
            string lastName = "Su@rez"; // TODO: Initialize to an appropriate value
            char gender = 'M'; // TODO: Initialize to an appropriate value
            Random rand = new Random();
            DateTime birthday = DateTime.Now.AddYears(-18); // TODO: Initialize to an appropriate value
            string email = "pedro" + rand.Next(400) + "@"; // TODO: Initialize to an appropriate value
            string password = "qweraadsdf"; // TODO: Initialize to an appropriate value
            string rePassword = "qwertsdfs"; // TODO: Initialize to an appropriate value
            string department = "Cochabamba"; // TODO: Initialize to an appropriate value
            string city = "Cercado"; // TODO: Initialize to an appropriate value
            string movilephone = "fail" + rand.Next(79999999); // TODO: Initialize to an appropriate value
            string phone = "fail" + rand.Next(4999999); // TODO: Initialize to an appropriate value
            Collection<RegisterError> actual;
            actual = UserRegistrationManager.RegisterUser(firstName, lastName, gender, birthday, email, password, rePassword, department, city, movilephone, phone);
            Assert.AreNotEqual(0, actual.Count);
        }

    }
}
